package chan.com.huishang.ui.activity;


import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import chan.com.huishang.R;
import chan.com.huishang.presenter.impl.SplashPresenterImpl;
import chan.com.huishang.iviews.ISplashViews;
import chan.com.mvplib.factory.CreatePresenter;
import chan.com.mvplib.view.activity.AbstractMvpActivity;

/**
 * Created by chen on 2017/12/25.
 */
@CreatePresenter(value = SplashPresenterImpl.class)
public class SplashActivity extends AbstractMvpActivity<ISplashViews, SplashPresenterImpl> implements ISplashViews {
    private String TAG = "SplashActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        if (savedInstanceState != null) {
            boolean a = savedInstanceState == null ? true : false;
            Log.e(TAG, "MainActivity onCreate 测试" + a);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        getMvpPresenter().checkUpdate();

    }

    @Override
    public void showUpdatedialog() {
        Toast.makeText(this, "当前最新版本不需要更新", Toast.LENGTH_LONG).show();
        enterMianActivity();
    }

    @Override
    public void showUpdateprogress(int percent, int total) {

    }

    @Override
    public void downloadError(Exception e) {

    }

    @Override
    public void downloadSuccess(String text) {

    }

    @Override
    public void enterMianActivity() {
        try {
            Thread.sleep(5000);
            startActivity(new Intent(this, MainActivity.class));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
